Advertisement
Leon_Lejon

.EXECUTIVE

May 17th, 2024 (edited)
468
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local w,h = term.getSize()
  2.  
  3. --Center Text
  4.  
  5. function printCentered (y,s)
  6.     local x = math.floor((w - string.len(s)) /2)
  7.     term.setCursorPos(x,y)
  8.     term.clearLine()
  9.     term.write(s)
  10. end
  11.  
  12. --Drawmenu
  13.  
  14. local nOption = 1
  15.  
  16. local function drawMenu()
  17.     term.setBackgroundColor(colors.cyan)
  18.     term.clear()
  19.     term.setCursorPos(1,1)
  20.     logo = paintutils.loadImage("os/.logo")
  21.     paintutils.drawImage(logo, 1, 1)
  22.     term.setBackgroundColor(colors.cyan)
  23.    
  24.     term.setCursorPos(w-11,1)
  25.     if nOption == 1 then
  26.         term.write("Worm")
  27.     elseif nOption == 2 then
  28.         term.write("Time")
  29.     elseif nOption == 3 then
  30.         term.write("Adventure")
  31.     elseif nOption == 4 then
  32.         term.write("Paint")
  33.     elseif nOption == 5 then
  34.         term.write("Exit")
  35.     else
  36.         end
  37. end    
  38.  
  39. --GUI
  40.  
  41. term.clear()
  42. local function drawFrontend()
  43.     printCentered(math.floor(h/2) -3, "")
  44.     printCentered(math.floor(h/2) -2, "EXECUTIVE")
  45.     printCentered(math.floor(h/2) -1, "")
  46.     printCentered(math.floor(h/2) + 0, (nOption == 1 and "[ Worm ]") or "Worm")
  47.     printCentered(math.floor(h/2) + 1, (nOption == 2 and "[ Time ]") or "Time")
  48.     printCentered(math.floor(h/2) + 2, (nOption == 3 and "[ Adventure ]") or "Adventure")
  49.     printCentered(math.floor(h/2) + 3, (nOption == 4 and "[ Paint ]") or "Paint")
  50.     printCentered(math.floor(h/2) + 4, (nOption == 5 and "[ Exit ]") or "Exit")
  51. end
  52.  
  53. --Display
  54.  
  55. drawMenu()
  56. drawFrontend()
  57.  
  58. while true do
  59.     local e,p = os.pullEvent()
  60.         if e == "key" then
  61.             local key = p
  62.             if key == 17 or key == 200 then
  63.            
  64.                 if nOption > 1 then
  65.                     nOption = nOption -1
  66.                     drawMenu()
  67.                     drawFrontend()
  68.                 end
  69.             elseif key == 31 or key == 208 then
  70.                 if nOption < 5 then
  71.                     nOption = nOption +1
  72.                     drawMenu()
  73.                     drawFrontend()
  74.                 end
  75.         elseif key == 28 then
  76.             break
  77. end
  78. end
  79. end
  80.  
  81. term.clear()
  82.  
  83. --Conditions
  84. if nOption == 1 then
  85.     term.setBackgroundColor(colors.black)
  86.     shell.run("worm")
  87. elseif nOption == 2 then
  88.     term.setBackgroundColor(colors.black)
  89.     term.clear()
  90.     term.setCursorPos(1,1)
  91.      print("You are now in DOS mode. Write 'back' to return to interface.")
  92.     print("---------------------------------------------------")
  93.     shell.run("time")
  94. elseif nOption == 3 then
  95.     term.setCursorPos(1,1)
  96.     shell.run("adventure")
  97. elseif nOption == 4 then
  98.     term.setCursorPos(1,1)
  99.     print("What should the file be called?")
  100.     local path = read()
  101.     shell.run("paint", path)
  102. else
  103.     shell.run("os/.functions")
  104. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement